'use strict'

var Koa = require('koa')
var path = require('path')
var wechat = require('./wechat/g')
var util = require('./libs/util')
var wechat_file = path.join(__dirname,'./config/wechat.txt')

var config = {
	wechat:{
		appID: 'wx559980fa338673af',
		appsecret: '82dfdf9054974f44c5e6b4269c9197c2',
		Token: 'qweasdzxc123',
		getAccessToken: function(){
			return util.readFileAsync(wechat_file)
		},
		saveAccessToken: function(data){
			data = JSON.stringify(data)
			return util.writeFileAsync(wechat_file,data)
		}
	}
}

var app = new Koa();

app.use(wechat(config.wechat))

app.listen(3030)
console.log('Listening:3030')